#include<iostream>
#include<string>
using namespace std;
const int N = 110;
string mp[N];
bool st[N][N];
int n, m;
int x, y;	
int ans;
void dfs(int a, int b, char c)
{
	if (a < 0 || a >= n || b < 0 || b >= m) {
		return;
	}
	if (mp[a][b] != ' ') {
		if (mp[a][b] != c) {
			ans++;
		}
		c = mp[a][b];
		mp[a][b] = ' ';
	}
	if (c == 'D') {
		dfs(a + 1, b, c);
	}
	if (c == 'U') {
		dfs(a - 1, b, c);
	}
	if (c == 'L') {
		dfs(a, b - 1, c);
	}
	if (c == 'R') {
		dfs(a, b + 1, c);
	}
}
int main()
{
	scanf_s("%d%d%d%d", &n, &m, &x, &y);
	for (int i = 0; i < n; i++) {
		cin >> mp[i];
	}
	char c = mp[x - 1][y - 1];
	mp[x - 1][y - 1] = ' ';
	dfs(x - 1, y - 1, c);
	cout << ans << endl;
	return 0;
}